Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agent group flag for introspeciton commands #2826

Merged
merged 3 commits into from
Oct 19, 2023
Merged

Conversation

sahil-lakhwani
Copy link
Contributor

@sahil-lakhwani sahil-lakhwani commented Oct 19, 2023

Description of change

  • Add support --agent-group for introspection commands wherever needed
Checklist
  • Tested in playground or other setup
  • Screenshot (Grafana) from playground added to PR for 15+ minute run
  • Documentation is changed or added
  • Tests and/or benchmarks are included
  • Breaking changes

Summary by CodeRabbit

  • New Feature: Added the ability to filter and list agents based on specific agent groups. This is achieved through the new --agent-group flag added to the aperturectl agents and aperturectl cloud agents commands.
  • New Feature: Enhanced the aperturectl discovery entities command with the ability to specify the agent group and the entity to find by name or IP.
  • Documentation: Updated the help messages and documentation for the aperturectl commands to reflect the new features and usage.
  • Refactor: Updated the ListAgents and ListDiscoveryEntities functions to accept specific request parameters, improving the flexibility and specificity of agent and entity listing.

These changes provide users with more control and specificity when listing agents and discovery entities, improving usability and efficiency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 19, 2023

Walkthrough

The changes primarily focus on enhancing the functionality of the aperturectl tool and its underlying services by introducing the ability to filter agents based on a specified agent group. This is achieved by adding a new --agent-group flag to various commands and modifying the corresponding functions to accept an agentGroup parameter. The changes also include updates to the ListAgents and ListDiscoveryEntities RPCs to accept specific request parameters instead of an empty request.

Changes

File(s) Summary
api/aperture/cmd/v1/cmd.proto Updated ListAgents and ListDiscoveryEntities RPCs to accept specific request parameters. Added ListAgentsRequest message with agent_group field.
cmd/aperturectl/cmd/agents.go, cmd/aperturectl/cmd/cloud/agents.go Added --agent-group flag to agentsCmd command. Updated ListAgents function to accept agentGroup parameter.
cmd/aperturectl/cmd/cloud/discovery/entities.go, cmd/aperturectl/cmd/discovery/entities.go Introduced agentGroup and findBy flags to EntitiesCmd command. Updated ListDiscoveryEntities function to include agentGroup parameter.
cmd/aperturectl/cmd/utils/agents.go, cmd/aperturectl/cmd/utils/controller-client.go, cmd/aperturectl/cmd/utils/discovery.go Modified ListAgents and ParseEntities functions to accept agentGroup parameter. Updated ListAgents function signature in IntrospectionClient interface.
docs/content/reference/aperturectl/agents/agents.md, docs/content/reference/aperturectl/cloud/agents/agents.md, docs/content/reference/aperturectl/cloud/discovery/entities/entities.md, docs/content/reference/aperturectl/discovery/entities/entities.md Added --agent-group option to various aperturectl commands in the documentation.
pkg/agent-functions/agents/agents.go Modified ListDiscoveryEntities and GetAgents functions to accept and return agentGroup respectively. Added GetAgentsForGroup and flattenAgents functions.
pkg/cmd/controller.go Updated ListAgents and ListDiscoveryEntities functions in Handler struct to accept specific request parameters and use GetAgentsForGroup method.

"With a hop and a skip, we've made quite the trip, 🐇
Adding flags and tweaking bits, making everything fit. 🛠️
Now we can filter and sort, making our code more adroit. 🎩
Oh, what a joy, to improve and deploy! 🚀"


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between ba447b1 and 14c0da4.
Files ignored due to filter (6)
  • api/buf.lock
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.json.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.validate.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_grpc.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_vtproto.pb.go
Files selected for processing (13)
  • api/aperture/cmd/v1/cmd.proto (3 hunks)
  • cmd/aperturectl/cmd/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/utils/agents.go (1 hunks)
  • cmd/aperturectl/cmd/utils/controller-client.go (1 hunks)
  • cmd/aperturectl/cmd/utils/discovery.go (2 hunks)
  • docs/content/reference/aperturectl/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/cloud/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/discovery/entities/entities.md (1 hunks)
  • pkg/agent-functions/agents/agents.go (5 hunks)
  • pkg/cmd/controller.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/content/reference/aperturectl/agents/agents.md
Additional comments (Suppressed): 26
docs/content/reference/aperturectl/cloud/agents/agents.md (1)
  • 23-29: The addition of the --agent-group flag is well documented here. Ensure that the functionality of this flag is also explained in the Synopsis or Description section of the documentation for clarity.
      --agent-group string    Name of the agent group to list agents for
cmd/aperturectl/cmd/cloud/agents.go (2)
  • 15-15: The new --agent-group flag is introduced correctly. Ensure that the flag is documented in the user guide or help command.

  • 33-35: The ListAgents function now accepts ListAgentsRequest instead of Empty. This change is consistent with the PR summary. Make sure to update all calls to this function throughout the codebase.

docs/content/reference/aperturectl/discovery/entities/entities.md (1)
  • 33-39: The new --agent-group option has been added to the command-line interface. Ensure that the implementation of this option correctly filters the agents based on the provided group name. Also, verify that the documentation and help messages throughout the codebase have been updated to reflect this new option.
cmd/aperturectl/cmd/utils/agents.go (1)
  • 10-16: The function signature of ListAgents has been changed to include an agentGroup parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the agentGroup string is being correctly passed to the ListAgentsRequest.
cmd/aperturectl/cmd/cloud/discovery/entities.go (3)
  • 9-12: The introduction of the agentGroup variable is a good addition to allow users to specify an agent group when listing agents or discovery entities. Ensure that the agentGroup variable is properly sanitized before use to prevent potential security issues.

  • 15-16: The addition of the agent-group flag to the EntitiesCmd command is a good way to allow users to specify an agent group when listing agents or discovery entities. Ensure that the flag is properly documented in the user guide or help command.

  • 36-36: The ParseEntities function now takes an additional argument agentGroup. Ensure that the function definition of ParseEntities is updated to handle this new argument and that all calls to this function throughout the codebase have been updated to match the new signature.

cmd/aperturectl/cmd/agents.go (2)
  • 12-12: The --agent-group flag is added to the agentsCmd command. Ensure that the flag is documented in the user guide or help command.

  • 30-30: The function utils.ListAgents now requires an additional argument agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

cmd/aperturectl/cmd/utils/controller-client.go (1)
  • 22-22: The function signature for ListAgents has been changed from accepting an emptypb.Empty parameter to a cmdv1.ListAgentsRequest parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the new cmdv1.ListAgentsRequest parameter is being properly populated where this function is called.
pkg/cmd/controller.go (2)
  • 44-52: The function signature for ListAgents has been changed to accept a ListAgentsRequest instead of Empty. This change is in line with the PR summary, but ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the GetAgentsForGroup function in the Agents package correctly handles the AgentGroup field from the request.

  • 157-163: Similar to the ListAgents function, the ListDiscoveryEntities function now accepts a ListDiscoveryEntitiesRequest instead of Empty. Ensure that all calls to this function have been updated to match the new signature. Also, verify that the ListDiscoveryEntities function in the Agents package correctly handles the AgentGroup field from the request.

cmd/aperturectl/cmd/utils/discovery.go (2)
  • 15-16: The function signature of ParseEntities has been changed to include an additional parameter agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 55-57: The ListDiscoveryEntities function now accepts an agentGroup parameter. This is a good improvement as it allows for more specific queries, reducing the amount of data that needs to be processed and returned.

api/aperture/cmd/v1/cmd.proto (3)
  • 16-16: The ListAgents RPC method has been updated to accept ListAgentsRequest instead of google.protobuf.Empty. Ensure that all calls to this method throughout the codebase have been updated to match the new signature. Also, verify that the server-side implementation of this method has been updated to handle the new request type.

  • 77-79: The ListDiscoveryEntitiesRequest message type has been updated to include an agent_group field. This change allows the caller to specify an agent group when listing discovery entities. Ensure that all uses of this message type in the codebase have been updated to include the new field if necessary. Also, verify that the server-side implementation of the ListDiscoveryEntities method has been updated to handle the new field.

  • 101-103: The ListAgentsRequest message type has been introduced with an agent_group field. This change allows the caller to specify an agent group when listing agents. Ensure that all uses of this message type in the codebase have been updated to include the new field if necessary. Also, verify that the server-side implementation of the ListAgents method has been updated to handle the new field.

cmd/aperturectl/cmd/discovery/entities.go (3)
  • 15-18: The new variable agentGroup is introduced to specify the agent group for which the agents are to be listed. This is a good addition for filtering agents based on groups.

  • 20-23: The agentGroup flag is added to the EntitiesCmd command. Ensure that the flag is documented in the user guide or help command.

  • 78-86: The ListDiscoveryEntities function now accepts an agentGroup parameter. This is a good addition for filtering discovery entities based on agent groups. However, it's important to handle the case where the provided agentGroup does not exist. If the ListDiscoveryEntities function does not already handle this, consider adding error handling for this case.

pkg/agent-functions/agents/agents.go (5)
  • 4-10: The new imports fmt and strings are used for error handling and string manipulation respectively. Ensure that these packages are used in a way that doesn't introduce any potential issues such as format string vulnerabilities.

  • 46-49: The function ListFlowControlPoints now sends requests to the "default" agent group instead of all agents. This change could affect the behavior of the function if there are multiple agent groups. Make sure this change is intended and that it doesn't break any existing functionality.

  • 56-68: The function ListDiscoveryEntities now accepts an agentGroup parameter and uses it to get the agents for that group. This is a breaking change if there are any existing calls to this function that don't provide this parameter. Make sure all calls to this function have been updated to match the new signature.

  • 76-79: The function ListDiscoveryEntity now uses the flattenAgents function to get the first agent from the list of agents. This could change the behavior of the function if the order of the agents is important. Make sure this change is intended and that it doesn't break any existing functionality.

  • 100-158: The GetAgents function has been significantly refactored to return a map of agent groups to agents instead of a list of agents. This is a breaking change if there are any existing calls to this function that expect a list of agents. Make sure all calls to this function have been updated to handle the new return type. The new GetAgentsForGroup function and flattenAgents function have been added to support the new agent group functionality. These functions appear to be implemented correctly, but make sure they are tested thoroughly to catch any potential issues.

cmd/aperturectl/cmd/agents.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 14c0da4 and 1a15d9e.
Files selected for processing (1)
  • docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1 hunks)
Additional comments (Suppressed): 1
docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1)
  • 33-39: The new --agent-group flag has been added to the options. Ensure that the implementation of this flag is correctly handled in the code and that it doesn't break any existing functionality. Also, update any relevant documentation or help text to include this new option.

@sahil-lakhwani sahil-lakhwani marked this pull request as ready for review October 19, 2023 07:14
@sahil-lakhwani sahil-lakhwani requested review from a team as code owners October 19, 2023 07:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Commits Files that changed from the base of the PR and between 7415812 and d819d61.
Files ignored due to filter (5)
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.json.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.validate.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_grpc.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_vtproto.pb.go
Files selected for processing (14)
  • api/aperture/cmd/v1/cmd.proto (3 hunks)
  • cmd/aperturectl/cmd/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/utils/agents.go (1 hunks)
  • cmd/aperturectl/cmd/utils/controller-client.go (1 hunks)
  • cmd/aperturectl/cmd/utils/discovery.go (2 hunks)
  • docs/content/reference/aperturectl/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/cloud/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1 hunks)
  • docs/content/reference/aperturectl/discovery/entities/entities.md (1 hunks)
  • pkg/agent-functions/agents/agents.go (5 hunks)
  • pkg/cmd/controller.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/content/reference/aperturectl/agents/agents.md
Additional comments (Suppressed): 28
docs/content/reference/aperturectl/discovery/entities/entities.md (1)
  • 36-36: The new --agent-group flag has been added correctly to the options list. Ensure that the functionality of this flag has been implemented correctly in the code and that it is working as expected. Also, verify that the flag's description is accurate and clear to the users.
cmd/aperturectl/cmd/utils/agents.go (1)
  • 10-16: The function ListAgents now takes an additional parameter agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the agentGroup string is being correctly populated and passed in all contexts where ListAgents is called.
docs/content/reference/aperturectl/cloud/agents/agents.md (1)
  • 26-26: The addition of the --agent-group flag is consistent with the summary of the pull request. Ensure that the functionality of this flag has been properly implemented and tested in the codebase. Also, verify that the flag's behavior is correctly documented, i.e., it should filter the agents based on the specified agent group.
cmd/aperturectl/cmd/utils/controller-client.go (1)
  • 22-22: The function signature for ListAgents has been changed to accept a ListAgentsRequest instead of Empty. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the ListAgentsRequest message includes the agent_group field as mentioned in the PR summary.
cmd/aperturectl/cmd/cloud/agents.go (2)
  • 11-11: The new flag --agent-group is introduced to filter the agents by group. Ensure that the flag is properly documented and users are aware of its usage.

  • 29-29: The ListAgents function is now being called with the agentGroup parameter. Make sure that the function handles the case when agentGroup is an empty string (i.e., the flag is not provided by the user), and it should list all agents as it did before.

docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1)
  • 33-39: The new --agent-group flag has been added to the options for the entities command. This allows users to specify an agent group when listing agents. Ensure that the functionality of this flag has been thoroughly tested and that the documentation accurately reflects its usage and behavior.
cmd/aperturectl/cmd/utils/discovery.go (2)
  • 15-16: The function signature of ParseEntities has been changed to include an additional parameter agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 55-57: The ListDiscoveryEntities function now accepts an agentGroup parameter. This is a good improvement as it allows for more specific queries, reducing the amount of data that needs to be processed and returned, which can lead to performance improvements.

cmd/aperturectl/cmd/agents.go (2)
  • 12-12: The new flag --agent-group is introduced to filter the agents by group. Ensure that the flag is properly documented and users are aware of its functionality. Also, verify that the flag is working as expected in different scenarios, such as when the group name is not provided, when an invalid group name is provided, and when a valid group name is provided.

  • 30-30: The function ListAgents now takes an additional argument agentGroup. Ensure that this change is reflected wherever this function is called. Also, verify that the function handles the agentGroup argument correctly, especially in edge cases like when the agentGroup is an empty string or when it doesn't match any existing agent group.

cmd/aperturectl/cmd/cloud/discovery/entities.go (2)
  • 16-16: The agent-group flag has been added to the EntitiesCmd command. Ensure that the flag is properly documented and that users are aware of its functionality and usage.

  • 36-36: The ParseEntities function now takes an additional agentGroup argument. Ensure that the function handles this new argument correctly, especially in cases where it might be an empty string or a group that doesn't exist.

api/aperture/cmd/v1/cmd.proto (3)
  • 16-16: The ListAgents RPC method now takes a ListAgentsRequest instead of google.protobuf.Empty. Ensure that all calls to this method have been updated to pass a ListAgentsRequest object. Also, make sure that the server-side implementation of this method has been updated to handle the new request type.

  • 77-79: The ListDiscoveryEntitiesRequest message now includes an agent_group field. This change allows the caller to specify an agent group when listing discovery entities. Ensure that all uses of this message have been updated to include the agent_group field if necessary.

  • 101-103: The ListAgentsRequest message now includes an agent_group field. This change allows the caller to specify an agent group when listing agents. Ensure that all uses of this message have been updated to include the agent_group field if necessary.

pkg/cmd/controller.go (2)
  • 44-52: The function signature for ListAgents has been changed to accept a ListAgentsRequest instead of Empty. This change is consistent with the PR summary. However, ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the GetAgentsForGroup function correctly handles the case where req.AgentGroup is empty or null, as this could potentially break existing functionality if not handled properly.

  • 157-163: Similar to the ListAgents function, the ListDiscoveryEntities function now accepts a ListDiscoveryEntitiesRequest instead of Empty. Again, ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the ListDiscoveryEntities function correctly handles the case where req.AgentGroup is empty or null.

cmd/aperturectl/cmd/discovery/entities.go (2)
  • 15-18: The new variable agentGroup is introduced to specify the agent group for which the agents are to be listed. This is a good addition for filtering the agents based on their group.

  • 20-23: The --agent-group flag is added to the EntitiesCmd command. This allows users to specify an agent group when listing agents. Ensure that the flag is documented and users are aware of its usage.

pkg/agent-functions/agents/agents.go (8)
  • 4-10: The new imports fmt and strings are used for error handling and string manipulation respectively. Ensure that these packages are used in a way that aligns with the project's standards.

  • 46-49: The flattenAgents function is used to convert the map of agent groups to agent hostnames into a single slice of agent hostnames. This is a change from the previous version where the agents variable was already a slice. Ensure that this change does not affect the functionality of the ListFlowControlPoints function.

  • 56-59: Similar to the previous comment, the flattenAgents function is used here to convert the map of agent groups to agent hostnames into a single slice of agent hostnames. Ensure that this change does not affect the functionality of the ListAutoScaleControlPoints function.

  • 63-68: The ListDiscoveryEntities function now accepts an agentGroup parameter and uses the GetAgentsForGroup function to get the agents for the specified group. This is a change from the previous version where the GetAgents function was used to get all agents. Ensure that this change does not affect the functionality of the ListDiscoveryEntities function.

  • 76-79: The flattenAgents function is used here to convert the map of agent groups to agent hostnames into a single slice of agent hostnames. The first agent from the flattened list is used for the SendRequest function. This is a change from the previous version where the first agent from the agents slice was used. Ensure that this change does not affect the functionality of the ListDiscoveryEntity function.

  • 100-133: The GetAgents function has been significantly modified. It now returns a map of agent groups to agent hostnames instead of a slice of agent hostnames. The function also now extracts the agent group from the etcd key. Ensure that these changes do not affect the functionality of the GetAgents function and that the agent group is correctly extracted from the etcd key.

  • 135-150: The new GetAgentsForGroup function gets the agents for a specified agent group by calling the GetAgents function and filtering the returned map for the specified group. If no group is specified, it defaults to the "default" group. Ensure that this function correctly gets the agents for the specified group and that the default behavior is as expected.

  • 152-158: The new flattenAgents function converts the map of agent groups to agent hostnames into a single slice of agent hostnames. This function is used in several places in the code to convert the output of the GetAgents function into a format that can be used by the SendRequests and SendRequest functions. Ensure that this function correctly flattens the map and that it does not affect the functionality of the functions that use it.

cmd/aperturectl/cmd/discovery/entities.go Show resolved Hide resolved
Signed-off-by: Sahil Lakhwani <[email protected]>
Signed-off-by: Sahil Lakhwani <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between 50c8969 and c3f9f60.
Files ignored due to filter (5)
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.json.go
  • api/gen/proto/go/aperture/cmd/v1/cmd.pb.validate.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_grpc.pb.go
  • api/gen/proto/go/aperture/cmd/v1/cmd_vtproto.pb.go
Files selected for processing (14)
  • api/aperture/cmd/v1/cmd.proto (3 hunks)
  • cmd/aperturectl/cmd/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/agents.go (2 hunks)
  • cmd/aperturectl/cmd/cloud/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/discovery/entities.go (2 hunks)
  • cmd/aperturectl/cmd/utils/agents.go (1 hunks)
  • cmd/aperturectl/cmd/utils/controller-client.go (1 hunks)
  • cmd/aperturectl/cmd/utils/discovery.go (2 hunks)
  • docs/content/reference/aperturectl/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/cloud/agents/agents.md (1 hunks)
  • docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1 hunks)
  • docs/content/reference/aperturectl/discovery/entities/entities.md (1 hunks)
  • pkg/agent-functions/agents/agents.go (5 hunks)
  • pkg/cmd/controller.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/content/reference/aperturectl/agents/agents.md
Additional comments (Suppressed): 27
cmd/aperturectl/cmd/agents.go (2)
  • 12-12: The new flag agent-group is introduced to filter agents by group. Ensure that the flag is documented and users are aware of its usage. Also, verify that the flag is handled correctly in the ListAgents function.

  • 30-30: The function ListAgents now takes an additional argument agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

- return utils.ListAgents(client)
+ return utils.ListAgents(client, agentGroup)
docs/content/reference/aperturectl/discovery/entities/entities.md (1)
  • 33-39: The new --agent-group flag is introduced correctly in the documentation. Ensure that the flag is working as expected in the actual code and that it's properly tested.
docs/content/reference/aperturectl/cloud/agents/agents.md (1)
  • 23-29: The addition of the --agent-group flag is well documented here. Ensure that the functionality of this flag is also explained in the Synopsis or Description section of the documentation for clarity.
docs/content/reference/aperturectl/cloud/discovery/entities/entities.md (1)
  • 33-39: The new --agent-group string option is introduced to allow users to specify an agent group when listing agents. Ensure that the implementation of this option correctly filters the agents based on the provided agent group. Also, update the documentation to explain what happens when the provided agent group does not exist or does not have any agents.
cmd/aperturectl/cmd/utils/agents.go (1)
  • 10-16: The function ListAgents now takes an additional parameter agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the agentGroup string is being sanitized and validated before being used in the ListAgentsRequest to prevent potential security issues.
- func ListAgents(client IntrospectionClient) error {
+ func ListAgents(client IntrospectionClient, agentGroup string) error {
cmd/aperturectl/cmd/utils/controller-client.go (1)
  • 22-22: The function signature of ListAgents has been changed. It now accepts a *cmdv1.ListAgentsRequest instead of *emptypb.Empty. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the new request type is properly handled in the function's implementation.
cmd/aperturectl/cmd/cloud/discovery/entities.go (3)
  • 9-12: The introduction of the agentGroup variable is a good addition to allow users to specify an agent group when listing agents or discovery entities. This change is consistent with the PR summary.

  • 15-16: The addition of the agent-group flag to the EntitiesCmd command is consistent with the PR summary. Ensure that the flag's usage is documented in the user guide or help command.

  • 36-36: The ParseEntities function now takes an additional argument agentGroup. Ensure that the function definition and all its calls throughout the codebase have been updated to match this new signature.

pkg/cmd/controller.go (2)
  • 44-52: The function signature of ListAgents has been changed to accept a ListAgentsRequest instead of emptypb.Empty. This change is likely due to the addition of the --agent-group flag. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the GetAgentsForGroup function correctly handles the case where req.AgentGroup is empty or null, as this could potentially lead to unexpected behavior.

  • 157-163: The function signature of ListDiscoveryEntities has been changed to accept a ListDiscoveryEntitiesRequest instead of emptypb.Empty. This change is likely due to the addition of the --agent-group flag. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the ListDiscoveryEntities function correctly handles the case where req.AgentGroup is empty or null, as this could potentially lead to unexpected behavior.

cmd/aperturectl/cmd/discovery/entities.go (2)
  • 17-22: The addition of the agentGroup variable and the --agent-group flag is a good way to allow users to specify an agent group when listing agents or discovery entities. Ensure that the new flag is documented in the user guide or help command.

  • 81-83: The ListDiscoveryEntities function now accepts an agentGroup parameter. This is a significant change and it's important to ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the ListDiscoveryEntities function handles the case where agentGroup is an empty string, as the --agent-group flag defaults to an empty string.

cmd/aperturectl/cmd/cloud/agents.go (2)
  • 11-11: The agentGroup flag is added to the agentsCmd command. Ensure that the flag is properly documented and users are aware of its usage and implications.

  • 29-29: The ListAgents function has been replaced with utils.ListAgents. Ensure that the new function has the same functionality as the old one and that it handles the agentGroup parameter correctly. Also, make sure that error handling is properly implemented in the utils.ListAgents function.

cmd/aperturectl/cmd/utils/discovery.go (2)
  • 15-18: The function signature of ParseEntities has been changed to include an additional parameter agentGroup. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the agentGroup parameter is being correctly passed in all function calls.

  • 55-57: The ListDiscoveryEntitiesRequest now includes an AgentGroup field. This is a significant change and it's important to ensure that the server-side RPC ListDiscoveryEntities is updated to handle this new field. Also, verify that the agentGroup is being correctly populated in the request.

api/aperture/cmd/v1/cmd.proto (3)
  • 16-16: The ListAgents RPC method has been updated to accept a ListAgentsRequest instead of google.protobuf.Empty. This change is in line with the PR summary, which mentions that the ListAgents RPC is being modified to accept a new request type that includes an agent_group field. Ensure that all calls to this RPC throughout the codebase have been updated to match the new signature.

  • 77-79: The ListDiscoveryEntitiesRequest message now includes an agent_group field. This is consistent with the PR summary, which mentions that the ListDiscoveryEntities RPC is being modified to accept a new request type that includes an agent_group field. Ensure that all instances of ListDiscoveryEntitiesRequest in the codebase are updated to include this new field.

  • 101-103: The ListAgentsRequest message has been added with an agent_group field. This is consistent with the PR summary, which mentions that the ListAgents RPC is being modified to accept a new request type that includes an agent_group field. Ensure that all instances of ListAgentsRequest in the codebase are updated to include this new field.

pkg/agent-functions/agents/agents.go (6)
  • 4-10: The new hunk introduces two new imports: fmt and strings. Ensure that these are necessary for the new code and that they are used in the codebase. If they are not used, they should be removed to keep the code clean and maintainable.

  • 46-49: The flattenAgents function is used here to convert the map of agent groups to a slice of agent hostnames. This is a change from the previous version where the agents slice was used directly. This change seems to be in line with the new functionality of handling agent groups.

  • 56-59: Similar to the previous comment, the flattenAgents function is used here to convert the map of agent groups to a slice of agent hostnames. This change seems to be in line with the new functionality of handling agent groups.

  • 63-68: The function signature of ListDiscoveryEntities has been changed to include an agentGroup parameter. This is a breaking change and all calls to this function throughout the codebase should be updated to match the new signature. Also, the function now calls GetAgentsForGroup instead of GetAgents, which is in line with the new functionality of handling agent groups.

  • 76-79: The flattenAgents function is used here to convert the map of agent groups to a slice of agent hostnames. This is a change from the previous version where the agents slice was used directly. This change seems to be in line with the new functionality of handling agent groups. However, it's worth noting that only the first agent from the flattened list is used. If the order of agents matters, this could potentially lead to inconsistent results.

  • 100-158: The GetAgents function has been significantly modified to return a map of agent groups to agent hostnames instead of a slice of agent hostnames. This is a breaking change and all calls to this function throughout the codebase should be updated to match the new return type. The new GetAgentsForGroup function retrieves agents for a specific group, which is a new functionality. The flattenAgents function is a helper function that converts the map of agent groups to a slice of agent hostnames. These changes seem to be in line with the new functionality of handling agent groups.

cmd/aperturectl/cmd/cloud/agents.go Show resolved Hide resolved
@sahil-lakhwani sahil-lakhwani requested a review from a team October 19, 2023 14:34
@sahil-lakhwani sahil-lakhwani merged commit 5f7c26b into main Oct 19, 2023
@sahil-lakhwani sahil-lakhwani deleted the agent-group-flag branch October 19, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants